package com.yzc.controller;

import com.yzc.model.query.system.UpdatePassReq;
import com.yzc.result.Result;
import com.yzc.service.EmailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/email")
public class EmailController {

    @Autowired
    private EmailService emailService;  // 注入 EmailService

    // 处理邮件发送请求,将验证码存储到数据库中
    @GetMapping("/sendChekcode")
    public Result sendEmail(@RequestParam("emailAddress") String emailAddress) {
        return emailService.sendSimpleMessage(emailAddress);
    }

    @GetMapping("/checkCode")
    public Result checkCode(@RequestParam("emailAddress") String emailAddress, @RequestParam("chekCode") String chekCode) {
        return emailService.checkCode(emailAddress, chekCode);
    }
    @PostMapping("/updatePassword")
    public Result updatePassword(@RequestBody UpdatePassReq updatePassReq) {
        return emailService.updatePassword(updatePassReq);
    }


}
